#include "simpblazecl.h"
#include "pblazecl.h"
#include "glob.h"

/**
 * Contructor
 */
cl_simpblaze::cl_simpblaze(class cl_app *the_app):
  cl_sim(the_app)
{}

/**
 * Creates new microcontroller instance
 */
class cl_uc *
cl_simpblaze::mk_controller(void)
{
  int i = 0;
  const char *type= NIL;
  class cl_optref type_option(this);

  type_option.init();
  type_option.use("cpu_type");

  if ((type = type_option.get_value(type)) == NIL)
    type = "KCPSM3"; // default cpu type

  while ((cpus_pblaze[i].type_str != NULL) && (strcmp(type, cpus_pblaze[i].type_str) != 0))
    i++;

  if (cpus_pblaze[i].type_str == NULL)
  {
      fprintf(stderr, "Unknown processor type. "
	      "Use -H option to see known types.\n");

      return(NULL);
  }

  return(new cl_pblaze(cpus_pblaze[i].type, this));
}
